package org.colin.mapper;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.colin.dictPojo.DEntry;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 词条表 Mapper 接口
 * </p>
 *
 * @author LiRuiFeng
 * @since 2021-01-09
 */
public interface DEntryMapper extends BaseMapper<DEntry> {

    boolean createEntryTable(@Param("tableName") String newEntryTableName);

    int selectCountByTableName(@Param("tableName") String tableName);

    void addEntry(@Param("entry") DEntry dEntry, @Param("tableName") String tableName);

    void updateEntry(@Param("entry") DEntry dEntry, @Param("tableName") String tableName);

    HashMap selectEntryById(@Param("id") Integer id, @Param("tableName") String tableName);


    IPage<HashMap> selectEntryIsPage(Page<HashMap> pageE,@Param("tableName") String entryTableName ,  @Param("param") String param, @Param("strokes") Integer strokes, @Param("hsk") Integer hsk, @Param("language") Integer language, @Param("convType") Integer convType);

    Integer selectCountByLevel(@Param("tableName") String tableName, @Param("levelId") Integer id);


    List<String> selectEntryGroupByPinYinIndex(@Param("tableName") String tableName, @Param("levelId")Integer levelId, @Param("py")String sp);

    List<Integer> selectEntryGroupByStrokesIndex(@Param("tableName") String tableName, @Param("levelId")Integer levelId);

    List<String> selectPinYinBySD(@Param("tableName")String entryTableName, @Param("studyLevel")Integer studyLevel, @Param("pinyin")String pinyin);

    List<HashMap> selectEntryDetailByPinYin(@Param("tableName")String entryTableName, @Param("studyLevel")Integer studyLevel, @Param("pinyin")String pinyin);

    List<Map> selectEntryByStrokesIndex(@Param("tableName")String tableName, @Param("levelId")Integer levelId, @Param("strokes")Integer strokes);

    List<Map> indexSearchByParam(@Param("tableName")String tableName, @Param("studyLevel")Integer studyLevel, @Param("param")String param);

    List<HashMap> selectNewEntryByPage(@Param("tableName")String entryTableName,@Param("studyLevel") Integer studyLevel, @Param("userName")String userName, @Param("newNum")int newNum);

    List entryStudy(@Param("tableName")String entryTableName, @Param("language")Integer language, @Param("studyLevel")Integer studyLevel, @Param("userName")String userName);

    List<HashMap> selectUserCollection(Page<HashMap> pageE,@Param("tableName") String entryTableName,@Param("language") Integer language,@Param("userName") String userName);

    DEntry selectEntryEntById(@Param("id") Integer id, @Param("tableName") String tableName);
}
